begintownscript;
variables;

body;

beginstate INIT_STATE;
	set_name(6,"Raelnis");
	set_name(7,"Banek");

	set_level(8,15);
	set_level(38,11);
	set_level(39,11);

	add_range_to_group(21,24,1);

	set_crime_tolerance(1);

	if (get_flag(2,6) == 1)
		flip_terrain(59,35);

	if (get_flag(1,29) == 1)	{
		put_object_on_space(30,19,-1);
		put_object_on_space(31,19,-1);	}
break;

beginstate START_STATE;
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(7,"Doo be doo be doo...");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(7,"Wanna hear a knock-knock joke?");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(7,"It's so boring being a rock.");
break;

beginstate EXIT_STATE;
break;

beginstate 10;
	move_to_new_town(5,30,23);
break;

beginstate 11;
	move_to_new_town(5,18,23);
break;

beginstate 12;
	if (get_flag(1,26) == 0)	{
		reset_dialog();
		add_dialog_str(0,"This area is bright with crystalline light, reflecting off the cave ceiling and walls.  On a small pad is a bizzare creature, almost unmoving watching you and regarding you.",0);
		add_dialog_str(1,"A tall, skinny, grey humanoid clothed in simply a translucent cloak grips its wide lethal looking blade.  The bright green eyes study you, trying to determine if you are a threat.",0);
		add_dialog_str(2,"This creature appears to be a Vahnatai-- mysterious and wise beings living deep within the ground in large cavernous realms.",0);
		add_dialog_str(3,"After a few tense moments, it relaxes a little and moves nearer to speak with you.",0);
		add_dialog_choice(0,"Okay.");
		run_dialog(1);
		set_flag(1,26,1);
		begin_talk_mode(1);	}
break;

beginstate 13;
	if (get_flag(1,29) == 0)
		message_dialog("A magical barrier blocks your progress deeper into the cave.  There are no means to deactivate it nearby, so you should try to find a way past elsewhere.","");
break;

beginstate 14;
	if (get_flag(2,0) == 0)	{
		message_dialog("You enter a wide area with small paths leading around the edges of the cavern.  Your attention, however, is more directed toward the massive abyss before you.  Dropping in a small rock yields no noise.  Seems deep.","");
		set_flag(2,0,1);	}
break;

beginstate 15;
	if (get_flag(2,1) == 0)	{
		message_dialog("As you enter this underground building, you almost immediately sense that there is great evil nearby.  This place reeks of malevolence, and the blood on the floor doesn't put you at ease.","");
		set_flag(2,1,1);	}
break;

beginstate 16;
	message_dialog("Stupidly you blunder down into the pentagram pit, thinking that magically you'll find a way out, or maybe just not thinking at all.  Unfortunately, this pit was a torture pit, made to keep people from escaping.","Or even moving.  When you step near, you are immediately forced to refrain from movement, and you cannot break the curse.  The spell placed here lasted long and well, killing one last group of people.");
	kill_char(1000,2,0);
break;

beginstate 17;
	if (get_flag(2,2) == 0)
		set_terrain(39,11,267);
break;

beginstate 18;
	if (get_flag(2,2) == 0)
		set_terrain(35,8,267);
break;

beginstate 19;
	if (get_flag(2,2) == 0)
		set_terrain(39,5,267);
break;

beginstate 20;
	if (get_flag(2,3) == 0)	{
		message_dialog("The moment you enter this room you know something is wrong.  The thought of inevitable death passes through your mind, and for a moment it feels like you are surrounded by an inescapable, impenetrable wall of darkness.","The feeling passes, but it leaves you uncomfortable and nervous.");
		set_flag(2,3,1);	}
break;

beginstate 21;
	if (get_flag(2,2) == 0)	{
		message_dialog("Your doubts about this room are justified as the corpse in the center of the room starts to glow.  A whisk of purplish air flies from it to somewhere, and then all movement ceases for a moment.","A few seconds later you notice that's not all that was inhabiting the carcass.  A large creature steps out from the corpse as if it were walking out a trapdoor.  Its body shines with demonic fire, and it turns to you with a hungry look on its face.");
		set_flag(2,2,1);
		spawn_creature(8);	}
break;

beginstate 22;
	if (get_flag(2,4) == 0)	{
		message_dialog("As you enter the room you stumble on an old moth-eaten broom.  It appears this is a janitor's room.","");
		set_flag(2,4,1);	}
break;

beginstate 23;
	if (get_flag(2,5) == 0)	{
		message_dialog("Suddenly you notice the air in front of you is purple.  The purple mist flows around you, and then back in front of where it begins to materialize as ghostly beings.  These ghosts are not in the least friendly.","Darn.");
		set_flag(2,5,1);
		activate_hidden_group(2);	}
break;

beginstate 24;
	message_dialog("These books all contain dark curses and witchcraft, which are mostly bogus.  A few here and there contain summoning rites for fell demons, but all of them are entirely unsafe and death is gauranteed if you were to attempt it.","");
break;

beginstate 25;
	reset_dialog();
	add_dialog_str(0,"The book on the pedestal is unbelievably worn, and you are surprised that the pages don't crumble at your touch.  It contains some very interesting text.",0);
	add_dialog_str(1,"_The Oath of the Black Guild_",20);
	add_dialog_str(2,"_I pledge my soul and body to the Black Guild, and I shall serve the Guild and its masters for eternity.  Never shall I renounce this Oath or be eternal damnation upon me;  always will I uphold the code of the Guild._",0);
	add_dialog_str(3,"_May the darkness envelop me as I become one with death;  merging the essences of war, chaos, and pain into my being.  With the power granted me by these forces I shall strive to mend the plague that is life._",0);
	add_dialog_str(4,"_In death we shall rejoice.  I destroy all those who refuse the Way that is opened to them, sending them to pain rather than the stillness.  I call upon the dark powers that be to aid me; infuse my body with unholy power so that I may serve._",0);
	add_dialog_str(5,"This book shows that this place was apparently built by a group of cultists.  Their beliefs seem to follow that life is a plague.  It doesn't make you hopeful about what lies further in the building.",0);
	add_dialog_choice(0,"Okay.");
	run_dialog(1);
break;

beginstate 26;
	if (get_flag(2,6) == 0)	{
		message_dialog("When you enter into this small tunnel, you hear the shrill noise of cackling laughter from ahead.  There is sure to be something troublesome here.","");
		set_flag(2,6,1);	}
break;

beginstate 27;
	if (get_flag(2,7) == 0)	{
		message_dialog("This isn't a good sign;  two bright green runes lie between you and a single chest.  That means something bad will happen when you approach.","");
		set_flag(2,7,1);	}
break;

beginstate 28;
	if (get_flag(2,8) == 0)	{
		message_dialog("You brace yourself for some kind of harmful effect as you cross over the runes.  Nothing happens.  Strange.  Maybe the magic placed here has worn off by now.","");
		set_flag(2,8,1);	}
break;

beginstate 29;
	if (get_flag(2,9) == 0)	{
		message_dialog("Unfortunately, whatever was meant to be gaurded by the runes has been taken somewhere else.  The chest is utterly empty.","");
		set_flag(2,9,1);	}
break;

beginstate 30;
	if (get_flag(2,10) == 0)	{
		message_dialog("With a swirl of purple mist, another group of ethereal foes appears before you.","");
		set_flag(2,10,1);
		activate_hidden_group(3);	}
break;

beginstate 31;
	if (get_flag(2,12) == 0)	{
		force_view_center(12,24);
		force_instant_terrain_redraw();
		pause(15);
		spawn_creature(35);
		put_boom_on_char(35,2,0);
		run_animation_sound(10);
		pause(11);
		relocate_character(35,12,21);
		force_instant_terrain_redraw();
		pause(12);
		text_bubble_on_char(35,"Wha...");
		force_instant_terrain_redraw();
		pause(15);
		text_bubble_on_char(35,"");
		relocate_character(35,12,20);
		text_bubble_on_char(35,"Intruders!?");
		force_instant_terrain_redraw();
		pause(26);
		text_bubble_on_char(35,"");
		text_bubble_on_char(35,"Need more time!");
		force_instant_terrain_redraw();
		pause(20);
		text_bubble_on_char(35,"");
		set_character_pose(35,1);
		force_instant_terrain_redraw();
		pause(3);
		put_boom_on_char(35,4,0);
		run_animation_sound(54);
		pause(5);
		spawn_creature(38);
		put_boom_on_char(38,2,0);
		spawn_creature(39);
		put_boom_on_char(39,2,0);
		run_animation_sound(10);
		pause(2);
		set_character_pose(35,2);
		force_instant_terrain_redraw();
		pause(5);
		put_boom_on_char(35,2,0);
		erase_char(35);
		run_animation_sound(10);
		pause(5);
		force_view_center(12,28);
		force_instant_terrain_redraw();
		alert_char(38);
		alert_char(39);
		block_entry(1);
		set_flag(2,12,1);	}
break;

beginstate 32;
	if (get_flag(2,14) == 0)	{
		spawn_creature(46);
		put_boom_on_char(46,2,0);
		run_animation_sound(10);
		set_flag(2,14,1);	}
break;

beginstate 33;
	if (get_flag(2,15) == 0)	{
		spawn_creature(47);
		put_boom_on_char(47,2,0);
		run_animation_sound(10);
		set_flag(2,15,1);	}
break;

beginstate 34;
	if (get_flag(2,18) == 0)	{
		message_dialog("As you approach the door, for a moment you sense a nearly overwhelming force of evil and darkness. A strong malevolent force is somewhere beyond this door, it seems.","Better pack extra sandwiches just in case.");
		set_flag(2,18,1);	}
break;

beginstate 35;
	move_to_new_town(7,24,12);
break;